<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla view library
jimport('joomla.application.component.view');
 
/**
 * AnJoLinA View
 */
class AnJoLinAViewShowlogs extends JView
{
	
	/**
	 * Display the view
	 */
	public function display($tpl = null)
	{
		
		$this->state		= $this->get('State');

		
		// Check for errors.
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}
		
		$this->log = "";
		
		try {
			 $fullpath = JPath::find(JPATH_ROOT  . DS . 'logs' . DS . 'anjolina', "com_anjolina.log.php");
			 $this->path = $fullpath;
			 
			 if($fullpath!=""){
			 	$textfile = file_get_contents($fullpath);
			 	$this->log = $textfile; 
			 }	
			 $this->params = &JComponentHelper::getParams('com_anjolina');
				 
			 
			 
			 
		} catch (Exception $e) {
			 $this->path = "";
			 $this->log = ""; 
		}
		
		$this->addToolbar();
		parent::display($tpl);
	}

	/**
	 * Add the page title and toolbar.
	 *
	 * @since	1.7
	 */
	protected function addToolbar()
	{
		// Initialise variables.

		//$component = $this->state->get('filter.component');
		
		//$canDo		= null;
		// Get the results for each action.
		//$canDo = CategoriesHelper::getActions($component, $categoryId);

		// Need to load the menu language file as mod_menu hasn't been loaded yet.
		/*
		$lang = JFactory::getLanguage();
			$lang->load($component, JPATH_BASE, null, false, false)
		||	$lang->load($component, JPATH_ADMINISTRATOR.'/components/'.$component, null, false, false)
		||	$lang->load($component, JPATH_BASE, $lang->getDefault(), false, false)
		||	$lang->load($component, JPATH_ADMINISTRATOR.'/components/'.$component, $lang->getDefault(), false, false);
	*/
		

		// Load the category helper. //
		//require_once JPATH_COMPONENT.'/helpers/selectcategories.php';

		// Get the results for each action.
		//$canDo = CategoriesHelper::getActions($component, $categoryId);
		
	
		$title = JText::_('COM_ANJOLINA_LOG');
		

		// Prepare the toolbar.
		JToolBarHelper::title($title, 'swap48.png');//refresh.png
		
		JToolBarHelper::custom('toCat', 'forward.png', 'forward.png', JText::_('COM_ANJOLINA_SUBMENU_CAT'), false);
		JToolBarHelper::custom('toPlug', 'forward.png', 'forward.png', JText::_('COM_ANJOLINA_SUBMENU_PLUGIN'), false);
		JToolBarHelper::divider();
		
		/*
		JToolBarHelper::trash('deleteLog', 'Moped', true);
		JToolBarHelper::divider();
		JToolBarHelper::trash('deleteLog', 'COM_ANJOLINA_DEBUG_DEL', true);
		JToolBarHelper::trash('Showlog.deleteLog', 'COM_ANJOLINA_DEBUG_DEL', false);
		JToolBarHelper::divider();
		JToolBarHelper::custom('deleteLog', 'delete.png', 'delete.png', 'COM_ANJOLINA_DEBUG_DEL', false);
		JToolBarHelper::divider();
		JToolBarHelper::custom('utils::deleteLog', 'delete.png', 'delete.png', 'COM_ANJOLINA_DEBUG_DEL', false);
		JToolBarHelper::divider();
		JToolBarHelper::custom('Showlog.deleteLog', 'delete.png', 'delete.png', 'COM_ANJOLINA_DEBUG_DEL', false);
		JToolBarHelper::divider();
		JToolBarHelper::custom('Showlogs.deleteLog', 'delete.png', 'delete.png', 'COM_ANJOLINA_DEBUG_DEL', false);
		*/
		
		JToolBarHelper::custom('deleteLog', 'delete.png', 'delete.png', 'COM_ANJOLINA_DEBUG_DEL', false);
		JToolBarHelper::divider();
		JToolBarHelper::preferences('com_anjolina');

		//if ($canDo->get('core.admin')) {
//			JToolBarHelper::custom('selectcategories.rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false);
		//	JToolBarHelper::preferences('com_anjolina');
//			JToolBarHelper::divider();
		//}

	}
	
	

	
	/**
	 * Method to set up the document properties
	 *
	 * @return void
	 */
	protected function setDocument() 
	{
		$document = JFactory::getDocument();
		$document->setTitle(JText::_('COM_ANJOLINA_LOG'));
	}
}